package com.qcln;

import com.qcln.util.JedisUtils;
import redis.clients.jedis.Jedis;

import java.util.List;

public class JedisTest {
    public static void main(String[] args) {
        // 1.加载驱动
        // 2. 获取连接对象
//        Jedis jedis = new Jedis("192.168.200.11",6379);
        Jedis jedis = JedisUtils.getJedis();

        // 3. 执行操作
//        String hello = jedis.get("hello");
//        System.out.println(hello);
//        System.out.println(jedis.ping());

//        jedis.lpush("list1","a","b","c","d");
//        List<String> list1 = jedis.lrange("list1", 0, -1);
//        for (String s : list1) {
//            System.out.println(s);
//        }

        Long sadd = jedis.sadd("set1", "abc", "abc", "def","cc","cba");
        System.out.println(sadd);
        Long len = jedis.scard("set1");
        System.out.println(len);
        // 4. 关闭连接
        jedis.close();
    }
}
